#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>
#include <gdk/gdk.h>

#ifdef HILDON
  #include <hildon-widgets/hildon-program.h>
  #include <hildon-widgets/hildon-window.h>
  #include <libosso.h>
#endif

#include "interface.h"
#include "support.h"
#include "callbacks.h"

#include "appdata.h"
#include "knots.h"

gboolean tb_visible = TRUE;
gboolean is_fullscreen = FALSE;
gboolean show_knots = TRUE;
gboolean being_handled = FALSE;
gboolean is_dirty = FALSE;

gboolean have_fname = FALSE;

int kwidth, kheight;
int knot[255];

char fname[512];

int main (int argc, char *argv[]) {

  GError *error = NULL;

  gtk_init (&argc, &argv);

#ifdef HILDON
  /* create the hildon program and setup the title */
  program = HILDON_PROGRAM(hildon_program_get_instance());
  g_set_application_name("Knot 770");

  /* Create HildonWindow and set it to HildonProgram */
  window = HILDON_WINDOW(hildon_window_new());
  hildon_program_add_window(program, window);

  /* initialize osso library */
  osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
  g_assert (osso);
#else
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
#endif

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  gtk_set_locale ();

  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
  tiles = gdk_pixbuf_new_from_file (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps/" "tileset.png", &error);
  if (!tiles) {
    tiles = gdk_pixbuf_new_from_file ("./tileset.png", &error);
    if (!tiles) {
      g_print("Couldn't load tileset.png: %d - %s", error->code, error->message);
    }
  }

  newKnot(7, 5);

  create_window(window);

#ifndef HILDON
  gtk_window_set_default_size(GTK_WINDOW(window), 730, 450);
#endif

  gtk_widget_show_all(GTK_WIDGET(window));
  gtk_main ();

  return 0;
}
